package cn.tedu.fresheveryday.controller;

import cn.tedu.fresheveryday.pojo.entity.OrderDistribution;
import cn.tedu.fresheveryday.restful.JsonResult;
import cn.tedu.fresheveryday.service.IOderDistributionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "订单配送信息模块")
@RequestMapping(path = "/distribution", produces = "application/json;charset=utf-8")
public class OrderDistributionController {
    @Autowired
    private IOderDistributionService service;

    /**
     * 通过id修改配送信息
     * @param distribution
     * @return
     */
    @PostMapping("/updateById")
    @ApiOperation("通过id修改配送信息")
    public JsonResult<Void> updateById(@RequestBody OrderDistribution distribution) {
        service.updateById(distribution);

        return JsonResult.success("修改成功", null);
    }

    /**
     * 通过订单id查询订单配送信息
     * @param orderId
     * @return
     */
    @GetMapping("/selectByOrderId")
    @ApiOperation("通过订单id查询订单配送信息")
    @ApiImplicitParam(value = "orderId", name="orderId", required = true)
    public OrderDistribution selectByOrderId(Integer orderId) {
        return service.selectByOrderId(orderId);
    }

}